<template>
  <a-drawer
    title="条目信息"
    :maskClosable="false"
    width=650
    placement="right"
    :closable="true"
    @close="close"
    :visible="reportInfoVisiable"
    style="height: calc(100% - 55px);overflow: auto;padding-bottom: 53px;">
    <div>
      <a-table
            :columns="columns"
            :dataSource="reportData"
            :pagination="false"
            class="components-table-demo-nested"
          ></a-table>
          <a-table
            slot="expandedRowRender"
            :columns="innerColumns"
            :dataSource="innerData"
            :pagination="false"
          ></a-table>
          </div>
  </a-drawer>
</template>
<script>

const columns = [
  { title: "检查时间", dataIndex: "time", key: "time" },
  { title: "检查机构", dataIndex: "dept", key: "dpet" },
  { title: "检查形式", dataIndex: "type", key: "type" },
  { title: "检查人员", dataIndex: "person", key: "person" }
];

const innerColumns = [
  { title: "条款", dataIndex: "recordTerms", key: "recordTerms" },
  { title: "检查内容", dataIndex: "recordContent", key: "recordContent" },
  { title: "检查依据", dataIndex: "recordBasis", key: "recordBasis" },
  { title: "检查方式", dataIndex: "recordMode", key: "recordMode" },
  { title: "现场实际情况", dataIndex: "recordDesc", key: "recordDesc" },
  { title: "隐患分类", dataIndex: "recordClass", key: "recordClass" }
];

export default {
  name: 'ReportInfo',
  props: {
    reportInfoVisiable: {
      require: true,
      default: false
    },
    reportInfoData: {
      require: true
    }
  },
  data () {
    return {
      key: +new Date(),
      loading: true,
      innerData: [],
      reportData: [],
      columns,
      innerColumns,
    }
  },
  methods: {
    close () {
      this.reportData = []
      this.innerData = []
      this.$emit('close')
    }
  },
  computed: {
  
  },
  watch: {
    reportInfoVisiable () {
      if (this.reportInfoVisiable) {
        this.$get('record/getRecords/'+this.reportInfoData.reportId).then((r) => {
          this.innerData = r.data.rows
          let mode = ["", "查资料", "查现场", "现场询问", "现场考核"];
          let rclass = ["", "符合项", "一般隐患", "重大隐患"];
          for (let i = 0;i<this.innerData.length;i++){
            this.innerData[i].recordMode = mode[this.innerData[i].recordMode];
            this.innerData[i].recordClass = rclass[this.innerData[i].recordClass];
          }
        })
        let type = ["", "例行检查", "突击检查", "特殊日期检查"];
        this.reportData.push({
            key: this.reportInfoData.reportId,
            time: this.$dateUtil.formatDate(this.reportInfoData.createTime),
            dept: this.reportInfoData.officeName,
            type: type[this.reportInfoData.reportType],
            person: this.reportInfoData.reportPerson
        });
      }
    }
  }
}
</script>
